<template>
  <div class="box">
    <van-card v-for="item in list" :key="item.filmId">
      <template #tags>
        <van-tag plain type="danger" class="button" size="large" color="#ff5f16"
          >预约</van-tag
        >
      </template>
      <template #thumb>
        <img :src="item.poster" alt="" width="66px" height="92.52px" />
      </template>
      <template #title>
        <div class="title">
          {{ item.name }}<span>{{ item.item.name }}</span>
        </div>
      </template>
      <template #desc>
        <div class="label actors">主演:{{ item.actors | handlerActors }}</div>
        <div class="label">上映时间:{{ item.premiereAt | dateFormat }}</div>
      </template>
    </van-card>
  </div>
</template>
<script>
import Vue from 'vue'
import { Card, Tag } from 'vant'

Vue.use(Card)
Vue.use(Tag)
import api from '@/api'
export default {
  data() {
    return {
      list: []
    }
  },
  filters: {
    handlerActors(val) {
      if (val) {
        let arr = val.map((item) => item.name)
        return arr.join(' ')
      } else {
        return '暂无主演'
      }
    }
  },
  methods: {},
  created() {
    this.$http.get(api.getFuture).then((res) => {
      this.list = res.data.films
    })
  }
}
</script>
<style lang='scss' scoped>
.box {
  padding-bottom: 50px;
  .title {
    color: #191a1b;
    font-size: 16px;
    height: 22px;
    line-height: 22px;
    span {
      font-size: 9px;
      background-color: #d2d6dc;
      color: #fff;
      height: 14px;
      line-height: 14px;
      padding: 0 2px;
      border-radius: 2px;
      margin-left: 5px;
      position: relative;
      top: -2px;
    }
  }
  .label {
    font-size: 13px;
    margin-top: 4px;
    color: #797d82;
  }
  .button {
    position: absolute;
    right: 0;
    bottom: 40px;
  }
  .actors {
    width: 174px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
</style>
